<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>通过两种方式访问对象属性2</title>
</head>

<body>
    <p>有两种方式可以访问对象属性: </p>
    <p>你可以使用 .property 或 ["property"]。</p>
    <p id="demo"></p>
    <script>
        var person = {
            firstName: "John",
            lastName: "Doe",
            id: 5566
        };
        document.getElementById("demo").innerHTML =
            person["firstName"] + " " + person["lastName"];
    </script>
</body>

</html>